/*
 *  $TEAM_NAME Space Trader
 */
package models;

import java.util.LinkedList;
import java.util.List;
import java.util.Observable;

/**
 * Represents a participant in the game. It holds all information
 * important to an individual such as name, credits, etc.
 *
 * @author bradley
 * @version 1.0
 */

public class Character extends Observable {
	/**
	 * field
	 */
	protected String name;
	
	/**
	 * field
	 */
	protected int fighter, pilot, trader, engineer;
	
	/**
	 * field
	 */
	protected int credits;
	
	/**
	 * field
	 */
	protected List<Actions> characterActions;
	
	/**
	 * field
	 */
	protected List<Actions>  playerActions;
	
	/**
	 * No arg constructor
	 */
	public Character(){
		this.name = "";
	}
	
	/**
	 * Creates a new chracter with the input attributes
	 *
	 * @param name - Name of the character
	 * @param fighter - the fighter skill points
	 * @param pilot - the pilot skill points
	 * @param trader - the trader skill points
	 * @param engineer - the engineer skill points
	 */
	public Character (String name, int fighter, int pilot, int trader, int engineer) {
		this.name = name;
		this.fighter = fighter;
		this.pilot = pilot;
		this.trader = trader;
		this.engineer = engineer;
		
		this.characterActions = new LinkedList<Actions>();
		this.playerActions = new LinkedList<Actions>();
	}
	
	/**
	 * Sets the name of a character
	 *
	 * @param name - the name of the character
	 */
	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * Gets the name of a character
	 * @return the name of the character
	 */
	public String getName() {
		return this.name;
	}
	
	/**
	 * Sets the fighter skill
	 *
	 * @param skill - the skill amount
	 */
	public void setFighter(int skill) {
		this.fighter = skill;
	}

	/**
	 * Gets the fighter skill
	 * @return - the skill amount
	 */
	public int getFighter() {
        return fighter;
    }
	
	/**
	 * Sets the pilot skill
	 * @param skill - the skill amount
	 */
	public void setPilot(int skill) {
		this.pilot = skill;
	}

	/**
	 * The  getter for the pilot
	 * @return - the pilot skill
	 */
    public int getPilot() {
        return pilot;
    }

	/**
	 * Sets the trader skill
	 * @param skill - the skill points
	 */
	public void setTrader(int skill) {
		this.trader = skill;
	}
	
	/**
	 * Getter for trader skill
	 * @return - the trader skill points
	 */
	public int getTrader() {
        return trader;
    }

	/**
	 * Sets the engineering skill
	 * @param skill - the skill points
	 */
	public void setEngineer(int skill) {
		this.engineer = skill;
    }

	/**
	 * Getter for the engineering skill
	 * @return engineer skill
	 */
    public int getEngineer() {
        return engineer;
    }

    /**
     * Sets the players current credits
     * @param credits
     */
    public void setCredits(int credits) {
    	this.credits = credits;
    }
    
    /**
     * Gets the players current credits
     * @return the credits
     */
    public int getCredits() {
        return credits;
    }
    
    /**
     * Uses credits
     * @param used - the amount of credits
     * @return the credits left
     */
    public int useCredits(int used) {
        credits -= used;

        setChanged();
        return credits;
    }

    /**
     * Add credits to the player
     * @param add - the amount of credits to add
     * @return The amount of credits the player has
     */
    public int addCredits(int add) {
        credits += add;

        setChanged();
        return credits;
    }
    
    /**
     * The actions a character can perform
     * @author bradley
     */
    public enum Actions {
    	ATTACK,
    	FLEE,
    	TRADE, 
    	IGNORE,
    	SURRENDER
    }
    
    /**
     * The generic attack method. Note: This method does nothing,
     * however it will be overwriten within the subtypes of 
     * character.
     * @return the damage done
     */
    public int attack() {
    	return 0;
    }
    
    /**
     * Defends an attack
     * @param attack
     */
    public void defend(int attack) {
    	System.out.println("Defended.");
    }

    /**
     * Sets the characters actions
     * @param actions - the various actions 
     */
    public void setCharacterActions(Actions ... actions) {
    	for(Actions a : actions){
    		this.characterActions.add(a);
    	}
    }
    
    /**
     * Sets what actions the player can use against the character
     * @param actions
     */
    public void setPlayerActions(Actions ... actions) {
    	for(Actions a : actions){
    		this.playerActions.add(a);
    	}
    }

    /**
     * Getter for character actions
     * @return the character actions
     */
	public List<Actions> getCharacterActions() {
		return characterActions;
	}

	/**
	 * Setter for character actions
	 * @param characterActions - the character actions
	 */
	public void setCharacterActions(List<Actions> characterActions) {
		this.characterActions = characterActions;
	}

	/**
	 * Getter for player actions
	 * @return the player actions
	 */
	public List<Actions> getPlayerActions() {
		return playerActions;
	}

	/**
	 * Setter for player actions
	 * @param playerActions - the player actions
	 */
	public void setPlayerActions(List<Actions> playerActions) {
		this.playerActions = playerActions;
	}
    
	/**
	 * to string
	 * @return string
	 */
    public String toString() {
    	return "";
    }
}
